package com.bootdo.system.controller;

import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.common.utils.R;
import com.bootdo.common.utils.ServerUtils;
import com.bootdo.system.domain.ScanequipDO;
import com.bootdo.system.service.ScanequipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 主页数据显示控制层
 */
@Controller
@RequestMapping("/main/")
public class MainController {

    @Autowired
    private ScanequipService scanequipService;

    /**
     * 获取首页各种设备类型数据
     * @param scanequipDO
     */
    @ResponseBody
    @PostMapping("/getScanequipCount")
    public Map<String,Object> getScanequipCount(ScanequipDO scanequipDO){
        Map<String,Object> map = scanequipService.getScanequipCount(scanequipDO);
        return map;
    }

    /**
     * 获取首页服务器信息
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/getServerData")
    @ResponseBody
    public R server() throws Exception {
        ServerUtils server = new ServerUtils();
        server.copyTo();
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("cpuDO",server.getCpu());
        map.put("memDO",server.getMem());
        map.put("sysDO",server.getSys());
        map.put("sysFileList",server.getSysFiles());
        return R.ok(map);
    }

}
